package com.csjbot.snowbot_rogue.servers.slams.agent.Util;

import com.slamtec.slamware.geometry.PointF;
import com.slamtec.slamware.geometry.Size;
import com.slamtec.slamware.robot.Map;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

/**
 * Created by chenqi on 2017/2/28.
 */

public class MapBean implements Serializable {
    public Map getMap() {
        PointF origin = new PointF(getMap_origin_x(), getMap_origin_y());
        Size size = new Size(getMap_size_width(), getMap_size_height());
        PointF resolution = new PointF(getMap_resolution_x(), getMap_resolution_y());
        return new Map(origin, size, resolution, timestamp, data);
    }


    private float map_resolution_x;
    private float map_resolution_y;
    private float map_origin_x;
    private float map_origin_y;
    private int map_size_width;
    private int map_size_height;

    /**
     * 虚拟轨道
     */
    private List<MapLines> lines;

    public List<MapLines> getLines() {
        return lines;
    }

    public void setLines(List<MapLines> lines) {
        this.lines = lines;
    }


    /**
     * 虚拟墙
     */
    private List<MapWalls> walls;

    public List<MapWalls> getWalls() {
        return walls;
    }

    public void setWalls(List<MapWalls> walls) {
        this.walls = walls;
    }


    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }


    public float getMap_resolution_x() {
        return map_resolution_x;
    }

    public void setMap_resolution_x(float map_resolutio_x) {
        this.map_resolution_x = map_resolutio_x;
    }

    public float getMap_resolution_y() {
        return map_resolution_y;
    }

    public void setMap_resolution_y(float map_resolution_y) {
        this.map_resolution_y = map_resolution_y;
    }

    public float getMap_origin_x() {
        return map_origin_x;
    }

    public void setMap_origin_x(float map_origin_x) {
        this.map_origin_x = map_origin_x;
    }

    public float getMap_origin_y() {
        return map_origin_y;
    }

    public void setMap_origin_y(float map_origin_y) {
        this.map_origin_y = map_origin_y;
    }

    public int getMap_size_width() {
        return map_size_width;
    }

    public void setMap_size_width(int map_size_width) {
        this.map_size_width = map_size_width;
    }

    public int getMap_size_height() {
        return map_size_height;
    }

    public void setMap_size_height(int map_size_height) {
        this.map_size_height = map_size_height;
    }


    /**
     * 构造函数
     *
     * @param map   获取地图对象
     * @param track
     */
    public void setMap(Map map, List<MapWalls> walls, List<MapLines> track) {
        setMap_origin_x(map.getOrigin().getX());
        setMap_origin_y(map.getOrigin().getY());
        setMap_resolution_x(map.getResolution().getX());
        setMap_resolution_y(map.getResolution().getY());
        setMap_size_height(map.getDimension().getHeight());
        setMap_size_width(map.getDimension().getWidth());
        setData(map.getData());
        setTimestamp(map.getTimestamp());
        //固定版本号
        setWalls(walls);
        setLines(track);
    }


    private long timestamp;
    private byte[] data;

    private static final long serialVersionUID = 8711368828010083044L;

    @Override
    public String toString() {
        return "MapBean{" +
                "map_resolution_x=" + map_resolution_x +
                ", map_resolution_y=" + map_resolution_y +
                ", map_origin_x=" + map_origin_x +
                ", map_origin_y=" + map_origin_y +
                ", map_size_width=" + map_size_width +
                ", map_size_height=" + map_size_height +
                ", timestamp=" + timestamp +
                ", data=" + Arrays.toString(data) +
                '}';
    }
}
